package com.gxsyh.nantie.statements.management.provider.service.impl;

import com.gxsyh.nantie.statements.management.provider.domain.ApartmentOrderInfo;
import com.gxsyh.nantie.statements.management.provider.mapper.ApartmentOrderInfoMapper;
import com.gxsyh.nantie.statements.management.provider.service.ApartmentOrderInfoService;
import com.gxsyh.nantie.statements.management.provider.service.TbDepartmentService;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ApartmentOrderInfoServiceImpl implements ApartmentOrderInfoService {

    @Resource
    private ApartmentOrderInfoMapper apartmentOrderInfoMapper;

    @Resource
    private TbDepartmentService tbDepartmentService;


    @Override
    public List<ApartmentOrderInfo> selectApartmentOrder(Long payDepartmentId) {
        return apartmentOrderInfoMapper.selectApartmentOrder(payDepartmentId);
    }

    @Override
    public List<ApartmentOrderInfo> findorderStatusByApartmentOrder(Long payDepartmentId, Integer payStatus, Integer orderStatus) {
        List<ApartmentOrderInfo> apartmentOrderInfoList=apartmentOrderInfoMapper.findorderStatusByApartmentOrder(payDepartmentId,payStatus,orderStatus);

        for (ApartmentOrderInfo list: apartmentOrderInfoList)
        {
            String[] ordernum=list.getOrderNum().split("-");
            String num=ordernum[0];
            list.setNum(num);
            list.setDepartmentUserName(tbDepartmentService.selectAllBelongToDepartment(list.getDepartmentUserId()));


        }
        return apartmentOrderInfoList;
    }

    @Override
    public List<ApartmentOrderInfo> findAllorderStatusByApartmentOrder(Integer payStatus, Integer orderStatus) {
        List<ApartmentOrderInfo> apartmentOrderInfoList=apartmentOrderInfoMapper.findAllorderStatusByApartmentOrder(payStatus,orderStatus);

        for (ApartmentOrderInfo list: apartmentOrderInfoList)
        {
            String[] ordernum=list.getOrderNum().split("-");
            String num=ordernum[0];
            list.setNum(num);
            list.setDepartmentUserName(tbDepartmentService.selectAllBelongToDepartment(list.getDepartmentUserId()));

        }
        return apartmentOrderInfoList;
    }

}
